﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;

namespace haptic.src.engine
{
    class LevelIO
    {
        public static Level Deserialize(Scene oGame, IServiceProvider oServiceProvider, string sFilePath)
        {
            Level oLevel = null;
            XmlSerializer oSerializer = new XmlSerializer(typeof(Level));
            FileStream oFile = new FileStream(sFilePath, FileMode.Open);
            if ( oFile != null )
            {
                oLevel = (Level)oSerializer.Deserialize(oFile);
                oLevel.Init(oGame, oServiceProvider, sFilePath);
                oFile.Close();
            }

            return oLevel;
        }
        public static void Serialize(Level oLevel)
        {
            XmlSerializer oSerializer = new XmlSerializer(typeof(Level));
            FileStream oFile = new FileStream(oLevel.m_sFilePath, FileMode.Create);
            oSerializer.Serialize(oFile, oLevel);
            oFile.Close();
        }
    }
}
